home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / dviware / dvitovdu32 / src / pascal / dvireader.h < prev    next >
Text File  |  1991-11-10  |  8KB  |  142 lines

  1. (* DVIReader *)
  2.  
  3. CONST
  4.    ruletablesize  = 300;         (* maximum number of rules in a ruletable    *)
  5.    ruletablesizem = ruletablesize - 1;
  6.    chartablesize  = 3000;        (* maximum number of chars in a chartable    *)
  7.    chartablesizem = chartablesize - 1;
  8.    maxfontspec    = maxstring;   (* max length of a font file specification   *)
  9.    maxspeciallen  = maxstring;   (* maximum length of \special string         *)
  10.    maxTeXchar     = 255;         (* ignore character codes > 255              *)
  11.  
  12. TYPE
  13.    (* Information about the rules and characters appearing on a page is stored
  14.       in dynamic one-way lists to avoid imposing any limit on their numbers.
  15.       To reduce pointer overheads, the nodes in these lists contain large
  16.       tables (the values of ruletablesize and chartablesize have been chosen
  17.       so that the vast majority of DVI pages will only require one-node lists).
  18.       When interpreting a DVI page, DVIReader adds a new rule or character node
  19.       to the TAIL of the relevant list.  This is done so that when DVItoVDU
  20.       accesses such lists (starting at the head), rules and characters will be
  21.       processed in somewhat the same sequence as seen in the DVI file; i.e.,
  22.       top-to-bottom and left-to-right across the page.
  23.       Since a character list is part of the information stored for a font,
  24.       the precise sequence in which DVI characters are seen is not remembered.
  25.       Font information is also linked together in a one-way list, but the
  26.       ordering is more or less random (see, however, the SortFonts routine).
  27.    *)
  28.    ruleinfoptr = ^ruleinfo;
  29.    ruleinfo    =                          (* a node in a list of ruletables   *)
  30.       RECORD
  31.          rulecount : INTEGER;             (* number of rules in ruletable     *)
  32.          ruletable : ARRAY [0..ruletablesizem] OF
  33.             RECORD
  34.                hp, vp : INTEGER;          (* pixel coords of rule's ref point *)
  35.                wd, ht : INTEGER;          (* dimensions of rule in pixels     *)
  36.             END;
  37.          nextrule  : ruleinfoptr;         (* next node in rule list           *)
  38.       END;
  39.  
  40.    charinfoptr = ^charinfo;
  41.    charinfo    =                          (* a node in list of chartables     *)
  42.       RECORD
  43.          charcount : INTEGER;             (* number of chars in chartable     *)
  44.          chartable : ARRAY [0..chartablesizem] OF
  45.             RECORD
  46.                hp, vp : INTEGER;          (* pixel coords of char's ref point *)
  47.                code   : 0..maxTeXchar;    (* char's code and pixeltable index *)
  48.             END;
  49.          nextchar  : charinfoptr;         (* next node in char list           *)
  50.       END;
  51.  
  52.    (* DVIReader uses wd, ht, xo and yo to calculate minhp, minvp, maxhp and
  53.       maxvp.  dwidth and pwidth are used to advance horizontally.
  54.       The mapadr and bitmap fields are not used by DVIReader; they are used
  55.       by FontReader and the main program to load character bitmaps.
  56.    *)
  57.    pixeltableptr = ^pixeltable;
  58.    pixeltable    = ARRAY [0..maxTeXchar] OF
  59.       RECORD
  60.          wd, ht : INTEGER;       (* glyph width and height in pixels; they
  61.                                     define the size of the smallest box
  62.                                     containing all the black pixels           *)
  63.          xo, yo : INTEGER;       (* x and y offsets from top left corner
  64.                                     of glyph to character's reference point   *)
  65.          dwidth : INTEGER;       (* advance width in DVI units computed from
  66.                                     fix width stored in font file             *)
  67.          pwidth : INTEGER;       (* advance width in pixels computed from
  68.                                     fix width stored in font file             *)
  69.          mapadr : INTEGER;       (* byte offset of bitmap info in font file   *)
  70.          bitmap : int_or_mptr;   (* SYSDEP: starting address of bitmap        *)
  71.       END;
  72.  
  73.    fontinfoptr = ^fontinfo;
  74.    fontinfo    =                        (* a node in list of fonts            *)
  75.       RECORD
  76.          psfont      : BOOLEAN;         (* is this a PostScript font?         *)
  77.          fontused    : BOOLEAN;         (* is font used on current page?      *)
  78.          fontnum     : INTEGER;         (* DVI font number: -2^31 .. 2^30 - 1 *)
  79.          scaledsize  : INTEGER;         (* scaled font size in DVI units      *)
  80.          designsize  : INTEGER;         (* design size in DVI units           *)
  81.          fontarea    : string;          (* explicit font directory            *)
  82.          fontarealen : INTEGER;         (* length of fontarea                 *)
  83.          fontname    : string;          (* font name; e.g., "cmr10"           *)
  84.          fontnamelen : INTEGER;         (* length of font name                *)
  85.          fontspec    : string;          (* complete font file pathname        *)
  86.          fontspeclen : INTEGER;         (* length of fontspec                 *)
  87.          fontexists  : BOOLEAN;         (* can fontspec be opened?            *)
  88.          totalchars  : INTEGER;         (* number of chars from font on page  *)
  89.          charlist    : charinfoptr;     (* head of char information list      *)
  90.          chartail    : charinfoptr;     (* tail of char information list      *)
  91.          pixelptr    : pixeltableptr;   (* allocated once: 1st time font used *)
  92.          nextfont    : fontinfoptr;     (* next node in font list             *)
  93.       END;
  94.  
  95.    (* For the parameter in MoveToTeXPage: *)
  96.    TeXcounters = ARRAY [0..9] OF INTEGER;
  97.    TeXpageinfo =
  98.       RECORD
  99.          value     : TeXcounters;               (* \count0..\count9 values    *)
  100.          present   : ARRAY [0..9] OF BOOLEAN;   (* is counter relevant?       *)
  101.          lastvalue : 0..9;                      (* last relevant counter      *)
  102.       END;
  103.  
  104.    (* DVIReader also builds a list of \special info: *)
  105.    specialinfoptr = ^specialinfo;
  106.    specialinfo    = RECORD
  107.                        special     : string;
  108.                        hp, vp      : INTEGER;
  109.                        nextspecial : specialinfoptr;
  110.                     END;
  111.  
  112.  
  113. VAR
  114.    (* Most of these should be treated as read-only parameters:                *)
  115.    DVImag       : INTEGER;         (* magnification stored in DVI file        *)
  116.    totalpages   : INTEGER;         (* number of pages in DVI file             *)
  117.    totalfonts   : INTEGER;         (* number of fonts in DVI file             *)
  118.    currDVIpage  : INTEGER;         (* updated by MoveTo... calls              *)
  119.    currTeXpage  : TeXcounters;     (* ditto                                   *)
  120.    totalrules   : INTEGER;         (* number of rules on current page         *)
  121.    rulelist     : ruleinfoptr;     (* head of rule information list           *)
  122.    ruletail     : ruleinfoptr;     (* tail of rule information list           *)
  123.    speciallist  : specialinfoptr;  (* head of \special information list       *)
  124.    fontlist     : fontinfoptr;     (* head of font information list           *)
  125.    currfont     : fontinfoptr;     (* InterpretPage's current font info       *)
  126.    pageempty    : BOOLEAN;         (* is page empty of rules and chars?       *)
  127.    minhp        : INTEGER;         (* minimum horizontal pixel coordinate     *)
  128.    minvp        : INTEGER;         (* minimum vertical pixel coordinate       *)
  129.    maxhp        : INTEGER;         (* maximum horizontal pixel coordinate     *)
  130.    maxvp        : INTEGER;         (* maximum vertical pixel coordinate       *)
  131.  
  132. PROCEDURE InitDVIReader;                                               EXTERNAL;
  133. PROCEDURE OpenDVIFile (name : string);                                 EXTERNAL;
  134. PROCEDURE SetConversionFactor (resolution, magnification : INTEGER);   EXTERNAL;
  135. PROCEDURE MoveToDVIPage  (n : INTEGER);                                EXTERNAL;
  136. PROCEDURE MoveToNextPage (ascending : BOOLEAN);                        EXTERNAL;
  137. FUNCTION  MoveToTeXPage  (VAR newTeXpage : TeXpageinfo) : BOOLEAN;     EXTERNAL;
  138. FUNCTION  PixelRound (DVIunits : INTEGER) : INTEGER;                   EXTERNAL;
  139. PROCEDURE InterpretPage;                                               EXTERNAL;
  140. PROCEDURE SortFonts (VAR unusedlist : fontinfoptr);                    EXTERNAL;
  141. PROCEDURE CloseDVIFile;                                                EXTERNAL;
  142.